//
//  ConfirmGoodsTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/13.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "ConfirmGoodsTableViewCell.h"

@interface ConfirmGoodsTableViewCell ()
@property (nonatomic,strong)GLGWLabel * goodsNameLabel;
@property (nonatomic,strong)GLGWLabel * weightLabel;
@property (nonatomic,strong)GLGWLabel * specificationsLabel;
@property (nonatomic,strong)GLGWLabel * priceLabel;
@end

@implementation ConfirmGoodsTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {//107
        GLGWView * bankgroundView = [[GLGWView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(10), KScreenWidth-kWidthProportion_In_iPhoneTriploid(30), kHeightProportion_In_iPhoneTriploid(87)) inSuperView:self];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        //
        self.goodsNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:bankgroundView];
//        self.goodsNameLabel.text = @"三级螺纹钢";
        [self.goodsNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(20));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        //
        self.weightLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:bankgroundView];
//        self.weightLabel.text = @"50吨";
        self.weightLabel.textAlignment = NSTextAlignmentRight;
        [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.goodsNameLabel);
            make.left.equalTo(self.goodsNameLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(21)));
        }];
        
        [self.goodsNameLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
        [self.weightLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh) forAxis:(UILayoutConstraintAxisHorizontal)];
        //
        self.specificationsLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
//        self.specificationsLabel.text = @"HRB400E 400*300 河钢";
        [self.specificationsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.goodsNameLabel);
            make.top.equalTo(self.goodsNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(self.goodsNameLabel);
        }];
        //
        self.priceLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:bankgroundView];
        [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.specificationsLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.top.equalTo(self.specificationsLabel);
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
//        self.priceLabel.text = @"最高5000元/吨";
        self.priceLabel.textAlignment = NSTextAlignmentRight;
    }
    return self;
}

-(void)setCardModel:(CardInforModel *)cardModel{
    _cardModel = cardModel;
    self.goodsNameLabel.text = _cardModel.productName;
    self.weightLabel.text = [NSString stringWithFormat:@"%ld吨",_cardModel.weight];
    self.specificationsLabel.text = [NSString stringWithFormat:@"%@  %@  %@",koString(_cardModel.materialName),koString(_cardModel.specificationsName),koString(_cardModel.factoryName)];
    self.priceLabel.text = _cardModel.topPrice>0?[NSString stringWithFormat:@"最高%.2f元/吨",_cardModel.topPrice]:@"";
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
